package BIgnumber;

import java.util.Scanner;

public class begain {
    public static void main(String[] args) {
        //输入金额
        Scanner sc = new Scanner(System.in);
        int money;
        while (true){
        System.out.println("请输入一个金额");
         money = sc.nextInt();
        if (money >= 0 && money <= 9999999) {
            break;
        }
        else {
            System.out.println("输入金额无效，请重新输入");
        }
        }
        System.out.println(money);
        String moneystr ="";
        //获取整体大写
        while (true){
            int ge =money % 10;
           String capicalnumber = getnumber(ge);//获取每位数字
           moneystr = capicalnumber + moneystr;
           money = money/10;
            if (money ==0){
                break;
            }
        }
        /*System.out.println(moneystr);*/
        //前面插零
        int count = 7 - moneystr.length();
        for (int i = 0; i < count; i++) {
            moneystr = "零"+ moneystr;
        }
        /*System.out.println(moneystr);*/
        //插入单位
        String result ="";
        String[] arr = {"佰","拾","万","仟","佰","拾","元"};
        for (int i = 0; i < moneystr.length(); i++) {
            char c = moneystr.charAt(i);
            result = result + c + arr[i];
        }
        System.out.println(result);
    }
    //大写转换
    public static String getnumber(int number) {
        String[] arr = {"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
        return arr[number];
    }
}
